/**
 * @projectName leetode
 * @package cn.leetcode
 * @className cn.leetcode.t235
 * @copyright Copyright 2020 Thunisoft, Inc All rights reserved.
 */
package cn.leetcode;

/**
 * t235
 * @description
 * @author fei
 * @date 2025/9/12 17:07
 * @version 1.0
 */
public class t235 {
    public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
        if(root.val> p.val&&root.val>q.val){
            return lowestCommonAncestor(root.left,p,q);
        }
        if (root.val<p.val&&root.val<q.val){
            return lowestCommonAncestor(root.right,p,q);
        }
        return root;
    }
}
